class Solution(object):
    def isConvex(self, points):
        """
        :type points: List[List[int]]
        :rtype: bool
        """
        n = len(points)

        def judge(x, y):
            z = x[0] * y[1] - x[1] * y[0]
            if z > 0:
                return 1
            else:
                if z < 0:
                    return -1
                else:
                    return 0
        flag = False
        for i in range(n):
            x = [points[(i + 1) % n][0] - points[i % n][0], points[(i + 1) % n][1] - points[i % n][1]]
            y = [points[(i + 2) % n][0] - points[i % n][0], points[(i + 2) % n][1] - points[i % n][1]]
            now_judge = judge(x, y)
            if now_judge != 0:
                if not flag:
                    flag = True
                    base = now_judge
                else:
                    if now_judge != base:
                        return False
        return True

data = Solution()
points = [[0, 0], [0, 10], [20, -10]]
print(data.isConvex(points))
points = [[0, 0], [1, 0], [1, 1], [-1, 1], [-1, 0]]
print(data.isConvex(points))
points = [[0, 0], [1, 0], [2, 0]]
print(data.isConvex(points))
